import { piniaPersistConfig } from "@/config";
import { defineStore } from "pinia";
import { ref } from "vue";

const key: string = "roleData";

export const useRoleDataStore = defineStore(
  key,
  () => {
    /**
     * @description 角色数据
     */
    const roleData = ref();

    const isEdit = ref(false);

    /**
     * @description 清除角色数据缓存
     */
    function clearCacheHandler() {
      roleData.value = {};
    }

    return {
      isEdit,
      roleData,
      clearCacheHandler
    };
  },
  {
    persist: piniaPersistConfig(key, sessionStorage)
  }
);
